<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>019Vue中的作用域插槽</title>
  <script src="./vue.js"></script>
</head>
<body>
  <div id="root">
    <child></child>

    <h6>插槽作用域</h6>
    <child-two>
      <template slot-scope="props">
        <li>{{props.item}}---hello</li>
      </template>
    </child-two>
  </div>
  <script>
    var vm = new Vue({
      el: "#root",
      data: {

      },
      components: {
        "child": {
          data: function() {
            return {
              list: [1, 2, 3, 4]
            }
          },
          template: `<div>
                        <div  v-for="item of list">{{item}}</div>
                      </div>`
        },
        // 插槽作用域
        "childTwo": {
          data: function() {
            return {
              list: [2, 3, 4, 5, 6]
            }
          },
          template: `<div>
                        <slot v-for="item of list" :item=item></slot>
                    </div>`
        }
      }
    })
  </script>
</body>
</html>